import { mapActions, mapGetters } from 'vuex';

export default {
  data () {
    return {
      curMenuBtns: [],
      systematicBtns: [],
      authorityBtnsList: []
    }
  },
  computed: {
    ...mapGetters('permissions/systemBtns', [
      'getSystematicBtns', 'getCurMenuBtns'
    ])
  },
  methods: {
    ...mapActions('permissions/systemBtns', ['getCurMenuBtnsList']),

    handleAsyncEvents () {
      let opMenuName = sessionStorage.getItem('menuName')
      this.systematicBtns = this.getSystematicBtns(opMenuName) ? this.getSystematicBtns(opMenuName) : []
      sessionStorage.setItem('systematicBtns', JSON.stringify(this.systematicBtns))
      this.authorityBtnsList = JSON.parse(sessionStorage.getItem('authorityBtnsList'))
    },

    getBtnsFn () {
      const data = {
        parentMenuId: sessionStorage.getItem('menuId')
      }
      if(data.parentMenuId) {
        this.getCurMenuBtnsList({
          payload: {
            data,
          },
        })
      }
    },
  }
}
